package dao.oc_station_pla;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;


import entitybean.oc_station_pla.EntityBeanOc_Station_Pla;

public class DaoImpl_Oc_Station_Pla  extends HibernateDaoSupport implements Dao_Oc_Station_Pla{
	public void Insert_Oc_Station_Pla(EntityBeanOc_Station_Pla e)
	{
		this.getHibernateTemplate().save(e);
	}
	public void Update_Oc_Station_Pla(EntityBeanOc_Station_Pla e)
	{
		this.getHibernateTemplate().update(e);
	}@SuppressWarnings("unchecked")
	public void Delete_Oc_Station_Pla(String id)
	{
		List<EntityBeanOc_Station_Pla> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF' and id in("+id+")");	
		for(int i=0;i<list.size();i++)
		{
			EntityBeanOc_Station_Pla e=list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);
			
		}
	}
	@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Pla> Find_EntityBeanOc_Station_Pla()
	{
		List<EntityBeanOc_Station_Pla> list=new ArrayList<EntityBeanOc_Station_Pla>();
		list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF' ");
		return list;
	}
	@SuppressWarnings("unchecked")
	public EntityBeanOc_Station_Pla Find_EntityBeanOc_Station_Pla(Integer id)
	{
		EntityBeanOc_Station_Pla e= new EntityBeanOc_Station_Pla();
		List<EntityBeanOc_Station_Pla> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF' and id="+id);
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
	}
	@SuppressWarnings("unchecked")
	public EntityBeanOc_Station_Pla Find_Oc_Station_Pla_by_L_D(String L,String D,String voyage)
	{
		EntityBeanOc_Station_Pla e= new EntityBeanOc_Station_Pla();
		List<EntityBeanOc_Station_Pla> list=this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF' " +
				"and oc_voyage_id="+voyage+" and longitude='"+L+"' AND dimensionality='"+D+"'");
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
		
	}@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Pla> Find_Oc_Station_Pla_is_active()
	{
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF'");
		
	}@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Pla> Find_Oc_Station_Pla_by_oc_voyage_id(
			Integer id) {
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where del='OFF' and oc_voyage_id="+id);
	}@SuppressWarnings("unchecked")
	public List<EntityBeanOc_Station_Pla> Find_Oc_Station_Pla_by_oc_voyage_id(Integer id,Integer j)
	{
		return this.getHibernateTemplate().find("from EntityBeanOc_Station_Pla where territorial_waters="+j+" and del='OFF' and oc_voyage_id="+id);
		
	}
}
